-
Notifications
You must be signed in to change notification settings - Fork 67
Add HTTP service for creating snapshots #388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/config.h
Outdated
| APPCFG_CLASS | ||
| APPCFG_PARA(enable, bool, false); | ||
| APPCFG_PARA(domainSocket, std::string, ""); | ||
| APPCFG_PARA(address, std::string, "http://0.0.0.0:12345/snapshot"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://0.0.0.0:12345 is ok.
It should be used as an HTTP address for multiple functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use '127.0.0.1' as default for security reason
src/image_service.cpp
Outdated
| return ret; | ||
| } | ||
|
|
||
| int SnapshotHandler::handle_request(photon::net::http::Request& req, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move it to an individual file, such as 'api_server.cpp'
src/CMakeLists.txt
Outdated
| prefetch.cpp | ||
| tools/sha256file.cpp | ||
| tools/comm_func.cpp | ||
| snapshot_server.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
‘api_server.cpp’ is more suitable
also, snapshot_server.h --> api_server.h
src/snapshot_server.cpp
Outdated
| limitations under the License. | ||
| */ | ||
|
|
||
| #include "snapshot_server.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move it after #include "image_file.h"
src/example_config/overlaybd.json
Outdated
| "serviceConfig": { | ||
| "enable": false, | ||
| "domainSocket": "/var/run/overlaybd.sock" | ||
| "address": "http://127.0.0.1:12345" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
127.0.0.1:9862,
because the port of exporter is 9863 😂
src/config.h
Outdated
| APPCFG_CLASS | ||
| APPCFG_PARA(enable, bool, false); | ||
| APPCFG_PARA(domainSocket, std::string, ""); | ||
| APPCFG_PARA(address, std::string, "http://127.0.0.1:12345"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
12345-->9862
src/image_service.h
Outdated
| }; | ||
|
|
||
| struct ImageFile; | ||
| class SnapshotHandler; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class ApiHandler
Signed-off-by: Xun Chen <xunchen@hust.edu.cn>
|
LGTM |
What this PR does / why we need it:
This PR introduces an HTTP service for creating snapshots.
The service listens on 0.0.0.0 and handles snapshot creation requests. Upon receiving a request, it locates the corresponding image file by the given device ID and calls the image's create_snapshot() interface.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Please check the following list: